#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int arr[25][25][25] = { 0 };
	int l, w, h, q, x1, y1, z1;
	int x2, y2, z2;
	cin >> l >> w >> h >> q;
	int count = 0;
	while (q--) {
		cin >> x1 >> y1 >> z1;
		cin >> x2 >> y2 >> z2;
		for (int i = x1; i <= x2; i++) {
			for (int j = y1; j <= y2; j++) {
				for (int k = z1; k <= z2; k++) {
					arr[i][j][k] = 1;
				}
			}
		}
	}
	for (int i = 1; i <= l; i++) {
		for (int j = 1; j <= w; j++) {
			for (int k = 1; k <= h; k++) {
				if (arr[i][j][k] == 0) {
					count++;
			     }
			}
		}
	}
	cout << count << endl;
	return 0;
}